# @Time    : 2018/5/31 10:25
# @Author  : Jame
import os

#1.用户认证装饰器
def auth_type(role_type):
    from core import admin,student,teacher
    def auth(func):
        def wrapper(*args,**kwargs):
            if role_type=='admin':
                if not admin.admin_info['name']:
                    print('尚未登陆，请登陆后再选择')
                    admin.admin_login()
                else:
                    return func(*args,**kwargs)

            if role_type=='teacher':
                if not teacher.teacher_info['name']:
                    print('尚未登陆，请登陆后再选择')
                    teacher.teacher_login()
                else:
                    return func(*args,**kwargs)
            if role_type=='student':
                if not student.student_info['name']:
                    print('尚未登陆，请登陆后再选择')
                    student.student_login()
                else:
                    return func(*args,**kwargs)


        return wrapper

    return auth



#2.查看指定目录内文件的名称,生成列表返回
def get_files_name(files_dir):
    files_list=os.listdir(files_dir)

    return files_list
